<template>
  <div class="demo-basic-vueStudy">
      <div class="author-demo">
          <div>作者：谢鹏</div>
          <div>日期：2017/11/02</div>
      </div>
    <Menu mode="horizontal" active-name="1" @on-select="changeMenu">
      <MenuItem name="basic-basic-getData-demo-usage">
        <Icon type="ios-paper"></Icon>用法
      </MenuItem>
      <MenuItem name="basic-basic-getData-demo-get">
        <Icon type="ios-paper"></Icon>GET
      </MenuItem>
      <MenuItem name="basic-basic-getData-demo-post">
        <Icon type="ios-paper"></Icon>POST
      </MenuItem>
      <MenuItem name="basic-basic-getData-demo-put">
        <Icon type="ios-paper"></Icon>PUT
      </MenuItem>
      <MenuItem name="basic-basic-getData-demo-delete">
        <Icon type="ios-paper"></Icon>DELETE
      </MenuItem>
      <MenuItem name="basic-basic-getData-demo-all">
        <Icon type="ios-paper"></Icon>ALL
      </MenuItem>
    </Menu>
    <!-- demo的容器 -->
    <router-view class="demo-content"></router-view>
  </div>
</template>

<script>
  import hljs from 'highlight.js'
  import Ajax from '@zlst/js/Ajax/index.js'

  export default {
    mounted: function () {
      Ajax.init({
        apiList: {
          test: 'http://localhost:3000/book',
          test1: 'http://192.168.18.124/warehouse/inbound/lmsWmsGoodsReceivingCtrl/searchWithFilters',
          // login: 'http://192.168.10.241:7102/login'
        },
        checkToken: false
      })
      var getData = Ajax.methods;
      // getData.get('test', { id: 'warehouseID' })
      // getData.getUrl('http://localhost:3000/book', { id: 'warehouseID' })
      // getData.getRestful('test', { id: 'warehouseID' })
      // getData.putRestful('test', { id: 'warehouseID' })
      // getData.postRestful('test', { id: 'warehouseID' })
        //   getData.post('test', {
        //     username: '170160',
        //     password: '123456'
        //   });
        // getData.get('test1', {
        //     params: {
        //         page: 1,
        //         rows: 10,
        //         data: {
        //             "sord":"desc",
        //             "sidx":"createTime",
        //             "filters":{
        //                 "groupOp":"and",
        //                 "rules":[
        //                     {"field":"active","op":"eq","data":"0"},
        //                     {"field":"createTime","op":"lt","data":"2017-09-28 14:35:45"},
        //                     {"field":"createTime","op":"gt","data":"2017-08-29 14:35:45"}
        //                 ]
        //             }
        //         }
        //     }
        // })

      window.setTimeout(function () {
        $('.demo-basic-attrDemo pre code').each(function(i, block) {
          hljs.highlightBlock(block);
        });
      }, 0);
    },
    methods: {
      changeMenu: function (menuName){
        // 命名的路由
        this.$router.push({ name: menuName })
      }
    }
  }
</script>
